﻿@model IEnumerable<Common.Product>

@{
    ViewBag.Title = "HomePage";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<script type="text/javascript">
    function SortBy() {
        var Sorting = document.getElementById("ddlSort").value;
        $.ajax({
            url: '@Url.Action("Sorting","Home")',
            type: 'post',
            cache: false,
            data: { sorting: sort },
            success: function (result) { }
        });
        return false;
    }
</script>

<ul id="cssmenu">@Html.Action("SubMenu", "Website")</ul>
<div id="Main">
    <div id="Search">
        @using (Html.BeginForm("SearchBy", "Home"))
        {
           @Html.Label("Search Product By Name : ")@Html.TextBox("SearchString")<input type="submit" value="Search" />  
           @Html.Label(" | ")
           @Html.ActionLink("Sort By Lowest Price","SortBy","Home","products")
           @Html.Label(" | ")
           @Html.ActionLink("Sort By Highest Price", "SortBy", "Home", "products")
        }
    </div>
    <br />
    <div id="products">
        @foreach (var s in Model)
        {
            <div class='wrapper'>
                <ul id='ProductList'>  
                    <li class='itemStyle'>
                        <img alt="" src='@s.Image' width="50px" height="50px" class='image thumbnailStyle'/>
                        <h4 class='ItemText'>@s.Name</h4>
                        <h4 class='ItemText'>€@s.Price.ToString()</h4>
                        @Html.ActionLink("More Details", "Details", "Product", new { id = s.ID }, null)
                    </li>
                </ul>
            </div>
        }
    </div>
</div>